import org.opencv.core.Mat;
import org.opencv.core.Rect;
import org.opencv.highgui.Highgui;
import org.opencv.imgproc.Imgproc;


public class SeparateRegions {

	
	public static void saveRegions(){
		Mat screencapture = Highgui.imread("C:\\Workspace\\reco\\hbot\\svm_train_data\\read1.png");
		
		
		for(int i=1; i<=7; i++){
			Rect sourceRect = new Rect(	Regions.playerMinion_X_odd[i],
										Regions.playerMinion_Y, 
										Regions.region_width, 
										Regions.region_heigth);
			
			Mat region_i = screencapture.submat(sourceRect);
			
			// transform to greyscale
			Imgproc.cvtColor(region_i, region_i, Imgproc.COLOR_RGB2GRAY);
			//Imshow show_image1 = new Imshow("Region" + i + "after ColorConvert");
			//show_image1.showImage(region_i);
			
			Imgproc.threshold(region_i, region_i, 135, 255, Imgproc.THRESH_BINARY);
			//Imshow show_image = new Imshow("Region" + i + "after Thres");
			//show_image.showImage(region_i);
			String filename = "C:\\Workspace\\reco\\hbot\\svm_train_data\\predict"+i+".png";
			Highgui.imwrite(filename, region_i);
		}
		
	}
	
}
